package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节知会行项目中的多值
 * @author 代码创建
 */
public class FlowStepNotifyVth extends AbstractTableBean {

    private String FlowId; //流程Id 用于删除
    private String NotifyID; //知会ID
    private String FieldName; //字段类型
    private String Value; //值
    private String Label; //标题

    public static String TABLE_NAME = "Flow_StepNotifyVth";
    public static String TABLEKEY_NAME = "VthId";
    public FlowStepNotifyVth (IntegrateSql f){
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
    }

    public FlowStepNotifyVth (IntegrateSql f,ResultSet rs) throws SQLException{
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
        this.initParamToRs(rs);
    }

    public FlowStepNotifyVth (IntegrateSql f,String keyValue) throws SQLException{
        super(f,TABLE_NAME);
        this.setKeyName(TABLEKEY_NAME);
        setCodePrepare(selectCodeById().toString());
        prepareSql.setPstValue(1, keyValue);
        ResultSet rs = executeQuery();
        if(rs.next()){
            initParamToRs(rs);
        }else{
            initParam();
        }
        rs.close();
    }

    @Override
    protected void initParam() {
        FlowId = ""; //流程Id 用于删除
        NotifyID = ""; //知会ID
        FieldName = ""; //字段类型
        Value = ""; //值
        Label = ""; //标题
    }


    public void initParamToRs(ResultSet rs) throws SQLException{
        FlowId = rs.getString("FlowId"); //流程Id 用于删除
        NotifyID = rs.getString("NotifyID"); //知会ID
        FieldName = rs.getString("FieldName"); //字段类型
        Value = rs.getString("Value"); //值
        Label = rs.getString("Label"); //标题
        this.setKeyId(rs.getString("VthId"));
    }


    @Override
    protected int appendData() throws SQLException {
        int i = 1;
        prepareSql.setPstValue(i++,FlowId); //流程Id 用于删除
        prepareSql.setPstValue(i++,NotifyID); //知会ID
        prepareSql.setPstValue(i++,FieldName); //字段类型
        prepareSql.setPstValue(i++,Value); //值
        prepareSql.setPstValue(i++,Label); //标题
        return i;
    }


    @Override
    public Vector<String> getFields() {
        Vector<String> vec = new Vector<String>();
        vec.addElement("FlowId"); //流程Id 用于删除
        vec.addElement("NotifyID"); //知会ID
        vec.addElement("FieldName"); //字段类型
        vec.addElement("Value"); //值
        vec.addElement("Label"); //标题
        return vec;
    }


    /**
     * 设置流程Id 用于删除
     * @param flowid
     */
    public void setFlowId(String flowid){
        FlowId = flowid;
    }
    /**
     * 获取FlowId
     * @return 流程Id 用于删除
     */
    public String getFlowId(){
        return FlowId;
    }

    /**
     * 设置知会ID
     * @param notifyid
     */
    public void setNotifyID(String notifyid){
        NotifyID = notifyid;
    }
    /**
     * 获取NotifyID
     * @return 知会ID
     */
    public String getNotifyID(){
        return NotifyID;
    }

    /**
     * 设置字段类型
     * @param fieldname
     */
    public void setFieldName(String fieldname){
        FieldName = fieldname;
    }
    /**
     * 获取FieldName
     * @return 字段类型
     */
    public String getFieldName(){
        return FieldName;
    }

    /**
     * 设置值
     * @param value
     */
    public void setValue(String value){
        Value = value;
    }
    /**
     * 获取Value
     * @return 值
     */
    public String getValue(){
        return Value;
    }

    /**
     * 设置标题
     * @param label
     */
    public void setLabel(String label){
        Label = label;
    }
    /**
     * 获取Label
     * @return 标题
     */
    public String getLabel(){
        return Label;
    }

}
